function Eventable(){
    
}

Eventable.prototype = {
    $initEventable: function (){
        this._eventHandlers = {};
        this._eventRegistry = {};
    },
    $on: function (obj, type, listener){
        var id = Utils.guid(listener);
        if (!this._eventHandlers[id]) {
            this._eventHandlers[id] = Utils.bind(listener, this);
        }
        DOMUtils.addListener(obj, type, this._eventHandlers[id]);
    },
    $un: function (obj, type, listener){
        var id = Utils.guid(listener);
        if (this._eventHandlers[id]) {
            DOMUtils.removeListener(obj, type, this._eventHandlers[id]);
        }
    },
    addEventListener: function (type, listener){
        (this._eventRegistry[type] || (this._eventRegistry[type] = [])).push(listener);
    },
    removeEventListener: function (type, listener){
        Utils.removeItem(this._eventRegistry[type] || [], listener);
    },
    dispatchEvent: function (evt){
        var listeners = this._eventRegistry[evt.type];
        if (listeners) {
            var k = listeners.length;
            while (k --) {
                listeners[k].apply(this, [evt]);
            }
        }
    },
    $freeEventable: function (){
        this._eventHandlers = {};
        this._eventRegistry = {};
    }
};